home *** CD-ROM | disk | FTP | other *** search
/ Compass / Compass - Issue 1 (1994)(Alcatraz).adf / SOURCE / AGA_StartUp.s next >
Text File  |  1992-09-02  |  4KB  |  209 lines

  1. ; Graz, February 1994
  2.  
  3. *** StartUp by POSEIDON of ALCATRAZ ***
  4. *** Thanks to MIKE of SPREADPOINT   ***
  5. *** Works on A500 upto A4000/40     ***
  6. *** Written using DEVPAC            ***
  7.     
  8.     Include    CustomRegisterAGA.s
  9.  
  10. *** Exec ***
  11.  
  12. LVO_SuperVisor=-30
  13. FindTask=-294
  14. GetMsg=-372
  15. WaitPort=-384
  16. LVO_OldOpenLibrary=-408
  17. LVO_CloseLibrary=-414
  18.  
  19. *** Grafics ***
  20.  
  21. ActiView=34
  22. CopInit    =38
  23. LVO_LoadView=-222
  24. LVO_WaitTOF=-270
  25.  
  26. *** Use this const. for center your screen correct ***
  27.  
  28. SCR_X=40    PlaneWidth in bytes ( must be a multiple of 4 )
  29. SCR_Y=256    PlaneHeight in lines ( must be multiple of 2 )
  30. PLN=4        # of Planes
  31.  
  32. *** Writing this const. in the same named registers ***
  33.  
  34. DIW_START=($29-(SCR_Y-256)/2)*256+$81-(SCR_X*8-320)/2
  35. DIW_STOP=($29+(SCR_Y-256)/2)*256+$c1+(SCR_X*8-320)/2
  36. DDF_START=((($81-(SCR_X*8-320)/2)-17)/2)&$fff8
  37. DDF_STOP=DDF_START+(SCR_X*4-8)
  38.  
  39. *** This const. gives you the first line of your screen ***
  40. *** very useful for Copper Wait ***
  41.  
  42. COP0=$29-(SCR_Y-256)/2
  43.  
  44. *** Some often used macros ***
  45.  
  46. *** OpenLibrary    Name,Base,Error ***
  47.  
  48. M_OpenLib     MACRO
  49.         move.l    4.w,a6
  50.         lea    \1,a1
  51.         jsr    LVO_OldOpenLibrary(a6)
  52.         move.l    d0,\2
  53.         beq    \3
  54.         ENDM
  55.  
  56. *** CloseLibrary Base ***
  57.  
  58. M_CloseLib    MACRO
  59.         move.l    4.w,a6
  60.         move.l    \1,a1
  61.         jsr    LVO_CloseLibrary(a6)
  62.         ENDM
  63.  
  64. *** Try to use Sections for Code and Datas, so there
  65. *** will never be any problem with the cache !!! 
  66.  
  67.     Section    Programm,CODE
  68.  
  69. Start    move.l    4.w,a6            WB-startup ( no fucking GURU !!! )
  70.     sub.l    a1,a1
  71.     jsr    FindTask(a6)
  72.     move.l    d0,a4
  73.     tst.l    $ac(a4)
  74.     bne.s    fromCLI
  75.  
  76.     lea    $5c(a4),a0        get WorkbenchMessage
  77.     jsr    WaitPort(a6)
  78.     lea    $5c(a4),a0
  79.     jsr    GetMsg(a6)
  80.  
  81. fromCLI    M_OpenLib GfxName,GfxBase,Err
  82.     
  83.     move.l    GfxBase,a6        store old view
  84.     move.l    ActiView(a6),OldView
  85.  
  86.     move.l    #0,a1            set view to default
  87.     jsr    LVO_LoadView(a6)
  88.     jsr    LVO_WaitTOF(a6)
  89.     jsr    LVO_WaitTOF(a6)        
  90.  
  91.     lea    $dff000,a5
  92.     move.w     #$7fff,d0
  93.  
  94.     move.w    INTENAR(a5),-(a7)    clear all interrupts
  95.     or.w    #$8000,(a7)
  96.     move.w    d0,INTENA(a5)
  97.  
  98.     move.w  INTREQR(a5),-(a7)
  99.     or.w    #$8000,(a7)
  100.     move.w    d0,INTREQ(a5)
  101.  
  102.     move.w    DMACONR(a5),-(a7)    clear all DMA channels
  103.     or.w    #$8000,(a7)
  104.     move.w    d0,DMACON(a5)
  105.  
  106.     clr.l    MyVBR            use VBR register 
  107.     move.l    4.w,a6
  108.     move.w    296(a6),d0            
  109.     btst    #0,d0            if 60010 or higher processor
  110.     beq.s    noVBR
  111.  
  112.     lea    SuperV,a5        goto supervisormode
  113.     jsr    LVO_SuperVisor(a6)
  114.     bra.s    noVBR    
  115.  
  116. SuperV    movec    VBR,d0            and get VBR register
  117.     move.l    d0,MyVBR
  118.     rte
  119.  
  120. noVBR    lea    $dff000,a5
  121.     cmp.b    #$fc,LISAID(a5)        test AGA
  122.     bne.s    NotAGA
  123.     move.w    #$c00,BPLCON3(a5)    reset new BPLCON register to default
  124.     clr.w    FMODE(a5)        reset fetchmode to 16 bit
  125.     
  126. NotAGA    bsr.w    InitInterrupt            
  127.     
  128. *** Init. here your CopperList ***
  129.  
  130.     lea    $dff000,a5
  131.     move.l    #NewCopperList,COP1LCH(a5)    init. new CopperList
  132.     clr.w    COPJMP1(a5)
  133.     move.w    #DIW_START,DIWSTRT(a5)        set DisplayWindow
  134.     move.w    #DIW_STOP,DIWSTOP(a5)
  135.     move.w    #DDF_START,DDFSTRT(a5)        set DataFetch
  136.     move.w    #DDF_STOP,DDFSTOP(a5)
  137.     move.w    #PLN*$1000+$200,BPLCON0(a5)    init. BitPlaneControl
  138.     clr.l    BPLCON1(a5)
  139.  
  140.     move.w    #$c020,INTENA(a5)    switch on e.g. Level3Interrupt
  141.     move.w    #$83c0,DMACON(a5)    ???
  142.  
  143. Main    
  144.     
  145. *** Insert here your MainProgramm ***
  146.     
  147.     btst    #6,$bfe001
  148.     bne.s    Main
  149.  
  150. Exit    bsr.w    DeinitInterrupt
  151.     lea    $dff000,a5    
  152.     move.w    (a7)+,DMACON(a5)    restore DMA
  153.     move.w    (a7)+,INTREQ(a5)    restore interrupts
  154.     move.w    (a7)+,INTENA(a5)
  155.     move.l    GfxBase,a6        restore view
  156.     move.l    OldView,a1
  157.     jsr    LVO_LoadView(a6)
  158.     jsr    LVO_WaitTOF(a6)
  159.     jsr    LVO_WaitTOF(a6)
  160.     move.l    CopInit(a6),COP1LCH(a5)
  161.  
  162.     M_CloseLib GfxBase
  163. Err    moveq    #0,d0
  164.     rts
  165.  
  166. *** Use the VBR !!! e.g. Level3Interrupt ***
  167.  
  168. InitInterrupt
  169.     move.l    MyVBR,a0
  170.     move.l     $6c(a0),OldInt
  171.     move.l    #NewInterrupt,$6c(a0)
  172.     rts
  173.  
  174. DeinitInterrupt
  175.     move.l    MyVBR,a0
  176.     move.l     OldInt,$6c(a0)
  177.     rts
  178.  
  179. NewInterrupt
  180.     movem.l    d0-d7/a0-a6,-(sp)
  181.  
  182. *** Insert here your own Interrupt routine ***
  183.  
  184.     movem.l    (sp)+,d0-d7/a0-a6
  185.     move.w    #$0020,INTREQ+$dff000
  186.     rte
  187.  
  188. *** Remeber the cache !?! ***
  189.  
  190.     Section    Variables,DATA
  191.     
  192. GfxName dc.b    "graphics.library",0
  193.     even
  194. GfxBase    dc.l    0
  195. OldView    dc.l    0
  196. MyVBR    dc.l    0
  197. OldInt    dc.l    0
  198.  
  199. *** Sections for ChipMemory ***
  200.  
  201.     Section    GFX,DATA_C
  202.  
  203. NewCopperList    
  204.     dc.l    -2    create your own copperlist
  205.  
  206.     Section PLANES&BUFFER,BSS_C
  207.  
  208. Plane    ds.b    SCR_X*SCR_Y*PLN
  209.